#pragma once

#include <memory>
#include <vector>

#include "doc/document.h"
#include "doc/attribute_document.h"
#include "doc/index_document.h"
#include "util/pool/pool.h"

namespace hawking {
namespace indexlib {

/*
    NormalDocument use `Pool` is easily for deal with attribute
*/
class NormalDocument : public Document {
public:
    NormalDocument() : pool_(std::make_shared<Pool>(1024)) {}
    NormalDocument(std::shared_ptr<Pool> pool) : pool_(pool) {}
    virtual ~NormalDocument() = default;

    void SetOperatorType(util::IndexOp oper_type) {
        oper_type_ = oper_type;
    }
    util::IndexOp OperatorType() const {
        return oper_type_;
    }

    Pool* GetPool() {
        return pool_.get();
    }

    void SetIndexDocument(std::shared_ptr<IndexDocument> index_doc) {
        index_doc_ = index_doc;
    }

    std::shared_ptr<IndexDocument> GetIndexDocument() {
        return index_doc_;
    }

    void SetAttributeDocument(std::shared_ptr<AttributeDocument> attribute_doc) {
        attribute_doc_ = attribute_doc;
    }

    std::shared_ptr<AttributeDocument> GetAttributeDocument() {
        return attribute_doc_;
    }

    virtual uint64_t DocId() const override {
        return doc_id_;
    }
    void SetDocId(uint64_t doc_id) {
        doc_id_ = doc_id;
    }
    virtual util::IndexOp OperatroType() const override {
        return oper_type_;
    }

private:
    uint64_t doc_id_ = -1;
    std::shared_ptr<Pool> pool_;
    util::IndexOp oper_type_;

    std::shared_ptr<AttributeDocument> attribute_doc_;
    std::shared_ptr<IndexDocument> index_doc_;
};

}
}